import json
import requests
from src.base_class import BaseClass


class QYWXUtil(BaseClass):
    def __init__(self,logger=None):
        super().__init__(logger)
        self.base_url = ""
        self.logger = logger
        # self.access_token = None
        # self.agentid = config.get("qywx","agentid")
        # self.secret = config.get("qywx","secret")
        # self.corpid = config.get("qywx","corpid")
        # self.corpsecret = config.get("qywx","corpsecret")
    def send_robot_notic(self,title,msg):
        url ='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=dbfb4638-f53f-4829-b0b6-2439abe8a32c'
        
        message = f"""## {title}\n
> {msg}"""

        headers = {"Content-Type": "application/json"}

        data = {
            "msgtype": "markdown",
            "markdown": {
                "content": message
            }
        }

        resp = requests.post(url, data=json.dumps(data), headers=headers)
        print(resp.text)
        